﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Surface;
using Microsoft.Surface.Presentation;
using Microsoft.Surface.Presentation.Controls;

namespace Surfium
{
    /// <summary>
    /// Interaction logic for MyDragCursor.xaml
    /// </summary>
    public partial class MyDragCursor : SurfaceUserControl
    {
        public static readonly RoutedEvent DroppableNewLeaveEvent = EventManager.RegisterRoutedEvent(
            "DroppableNewLeave", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(MyDragCursor));

        public event RoutedEventHandler DroppableNewLeave
        {
            add { AddHandler(DroppableNewLeaveEvent, value); }
            remove { RemoveHandler(DroppableNewLeaveEvent, value); }
        }

        public void RaiseDroppableNewLeaveEvent()
        {
            RoutedEventArgs newEventArgs = new RoutedEventArgs(MyDragCursor.DroppableNewLeaveEvent);
            RaiseEvent(newEventArgs);
        }

        public static readonly RoutedEvent DroppableNewEnterEvent = EventManager.RegisterRoutedEvent(
            "DroppableNewEnter", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(MyDragCursor));

        public event RoutedEventHandler DroppableNewEnter
        {
            add { AddHandler(DroppableNewEnterEvent, value); }
            remove { RemoveHandler(DroppableNewEnterEvent, value); }
        }

        public void RaiseDroppableNewEnterEvent()
        {
            RoutedEventArgs newEventArgs = new RoutedEventArgs(MyDragCursor.DroppableNewEnterEvent);
            RaiseEvent(newEventArgs);
        }


        public static readonly RoutedEvent DroppableThisLeaveEvent = EventManager.RegisterRoutedEvent(
           "DroppableThisLeave", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(MyDragCursor));

        public event RoutedEventHandler DroppableThisLeave
        {
            add { AddHandler(DroppableThisLeaveEvent, value); }
            remove { RemoveHandler(DroppableThisLeaveEvent, value); }
        }

        public void RaiseDroppableThisLeaveEvent()
        {
            RoutedEventArgs newEventArgs = new RoutedEventArgs(MyDragCursor.DroppableThisLeaveEvent);
            RaiseEvent(newEventArgs);
        }

        public static readonly RoutedEvent DroppableThisEnterEvent = EventManager.RegisterRoutedEvent(
            "DroppableThisEnter", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(MyDragCursor));

        public event RoutedEventHandler DroppableThisEnter
        {
            add { AddHandler(DroppableThisEnterEvent, value); }
            remove { RemoveHandler(DroppableThisEnterEvent, value); }
        }

        public void RaiseDroppableThisEnterEvent()
        {
            RoutedEventArgs newEventArgs = new RoutedEventArgs(MyDragCursor.DroppableThisEnterEvent);
            RaiseEvent(newEventArgs);
        }



        public static readonly RoutedEvent DroppableOtherLeaveEvent = EventManager.RegisterRoutedEvent(
           "DroppableOtherLeave", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(MyDragCursor));

        public event RoutedEventHandler DroppableOtherLeave
        {
            add { AddHandler(DroppableOtherLeaveEvent, value); }
            remove { RemoveHandler(DroppableOtherLeaveEvent, value); }
        }

        public void RaiseDroppableOtherLeaveEvent()
        {
            RoutedEventArgs newEventArgs = new RoutedEventArgs(MyDragCursor.DroppableOtherLeaveEvent);
            RaiseEvent(newEventArgs);
        }

        public static readonly RoutedEvent DroppableOtherEnterEvent = EventManager.RegisterRoutedEvent(
            "DroppableOtherEnter", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(MyDragCursor));

        public event RoutedEventHandler DroppableOtherEnter
        {
            add { AddHandler(DroppableOtherEnterEvent, value); }
            remove { RemoveHandler(DroppableOtherEnterEvent, value); }
        }

        public void RaiseDroppableOtherEnterEvent()
        {
            RoutedEventArgs newEventArgs = new RoutedEventArgs(MyDragCursor.DroppableOtherEnterEvent);
            RaiseEvent(newEventArgs);
        }


        private MyWindow source;

        public MyWindow Source
        {
            get { return source; }
            set { source = value; }
        }

        public MyDragCursor()
        {
            InitializeComponent();
        }

        public MyDragCursor(String label, String link, Boolean dc, ImageSource isr, MyWindow source)
        {
      
            InitializeComponent();
            this.source = source;
            Label = label;
            this.link = link;
            this.directContact = dc;
            inner_image.Source = isr;
            testDirectContact();
        }

        private String label;
        public String Label
        {
            get { return label; }
            set
            {
                label = value;
                inner_label.Text = value;
            }
        }

        private String link;
        public String Link
        {
            get { return link; }
            set { link = value; }
        }

        private bool directContact = false;

        private void testDirectContact()
        {

            if (directContact)
            {
                sphere.Background = (RadialGradientBrush)Resources["OsmoBrush"];
                sphere.Height = Properties.Settings.Default.MenuItemDCSize;
                sphere.Width = Properties.Settings.Default.MenuItemDCSize;
            }
            else
            {
                sphere.Height = Properties.Settings.Default.MenuItemSize;
                sphere.Width = Properties.Settings.Default.MenuItemSize;
                Height = Properties.Settings.Default.MenuItemDCSize;
                Width = Properties.Settings.Default.MenuItemDCSize;
            }

        }
    }
}
